<script setup lang="ts">
import { ref } from "vue";
import ReCol from "@/components/ReCol";
import { formRules } from "../utils/rule";
import { FormProps } from "../utils/types";

const props = withDefaults(defineProps<FormProps>(), {
  formInline: () => ({
    title: "新增",
    taskStatus: "",
    moduleCode: "",
    taskType: "",
    endPos: "",
    moveObj: "",
    taskId: "",
    errorMsg: "",
    feedbackUrl: ""
  })
});

const ruleFormRef = ref();
const newFormInline = ref(props.formInline);
function getRef() {
  return ruleFormRef.value;
}

defineExpose({ getRef });
const sexOptions = [
  {
    value: 1,
    label: "入库任务"
  },
  {
    value: 2,
    label: "出库任务"
  },
  {
    value: 4,
    label: "同层移库"
  }
];
</script>

<template>
  <el-form
    ref="ruleFormRef"
    :model="newFormInline"
    :rules="formRules"
    label-width="82px"
  >
    <el-row :gutter="30">
      <re-col>
        <el-form-item label="任务号" prop="taskNo">
          <el-input
            v-model="newFormInline.taskNo"
            clearable
            placeholder="请输入任务号"
          />
        </el-form-item>
      </re-col>
      <re-col>
        <el-form-item label="任务类型" prop="taskType">
          <el-select
            v-model="newFormInline.taskType"
            placeholder="请选择任务类型"
            class="w-full"
            clearable
          >
            <el-option
              v-for="(item, index) in sexOptions"
              :key="index"
              :label="item.label"
              :value="item.value"
            />
          </el-select>
        </el-form-item>
      </re-col>
      <re-col>
        <el-form-item label="取货位" prop="startPos">
          <el-input
            v-model="newFormInline.startPos"
            clearable
            placeholder="请输入取货位"
          />
        </el-form-item>
      </re-col>
      <re-col >
        <el-form-item label="放货位" prop="endPos">
          <el-input
            v-model="newFormInline.endPos"
            clearable
            placeholder="请输入放货位"
          />
        </el-form-item>
      </re-col>
    </el-row>
    <!-- <el-row v-if="newFormInline.title === '修改'" :gutter="30">
      <re-col :value="12" :xs="24" :sm="24">
        <el-form-item label="任务状态" prop="task_status">
          <el-input
            v-model="newFormInline.taskStatus"
            clearable
            placeholder="请输入任务状态"
          />
        </el-form-item>
      </re-col>
      <re-col :value="12" :xs="24" :sm="24">
        <el-form-item label="任务分类" prop="module_code">
          <el-input
            v-model="newFormInline.moduleCode"
            clearable
            placeholder="请输入任务分类"
          />
        </el-form-item>
      </re-col>

      <re-col
        v-if="newFormInline.title === '修改'"
        :value="12"
        :xs="24"
        :sm="24"
      >
        <el-form-item label="目标位置" prop="end_pos">
          <el-input
            v-model="newFormInline.endPos"
            clearable
            placeholder="请输入目标位置"
          />
        </el-form-item>
      </re-col>
      <re-col :value="12" :xs="24" :sm="24">
        <el-form-item label="移动对象" prop="move_obj">
          <el-input
            v-model="newFormInline.moveObj"
            clearable
            placeholder="请输入移动对象"
          />
        </el-form-item>
      </re-col>

      <re-col :value="12" :xs="24" :sm="24">
        <el-form-item label="任务ID" prop="task_id">
          <el-input
            v-model="newFormInline.taskId"
            clearable
            placeholder="请输入任务ID"
          />
        </el-form-item>
      </re-col>
      <re-col :value="12" :xs="24" :sm="24">
        <el-form-item label="错误信息">
          <el-input
            v-model="newFormInline.errorMsg"
            clearable
            placeholder="请输入错误信息"
          />
        </el-form-item>
      </re-col>
      <re-col>
        <el-form-item label="回调地址">
          <el-input
            v-model="newFormInline.feedbackUrl"
            placeholder="请输入回调地址"
            type="textarea"
          />
        </el-form-item>
      </re-col>
    </el-row> -->
  </el-form>
</template>
